package com.disruptor.controller;

import com.disruptor.bean.ProConProperties;
import com.disruptor.disruptor.ProConMain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class IndexController {

	private Logger log = LoggerFactory.getLogger(getClass());

	@Autowired
	ProConProperties proConProperties;

	@RequestMapping("/")
	public String index(HttpServletRequest request, Model model){

		log.info("index 首页");

		model.addAttribute("prop",proConProperties);
		model.addAttribute("proStatus",ProConMain.isStartProducer());

		return "index";
	}


	@RequestMapping("/startProducer")
	public String startProducer(HttpServletRequest request, Model model){

		log.info("启动生产者……");

		ProConMain.startProducer();

		return "redirect:/";
	}



	@RequestMapping("/stopProducer")
	public String stopProducer(HttpServletRequest request, Model model){

		log.info("停止生产者……");

		ProConMain.stopProducer();

		return "redirect:/";
	}



}



















